package com.baidu.sggc.core.common.utils;

import com.baidu.sggc.service.AuditLogSyncService;
import com.baidu.sggc.service.AuditQueryLogSyncService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class AuditLogSyncTask {

    private final AuditLogSyncService syncService;
    private final AuditQueryLogSyncService queryLogSyncService;

    // 每隔1秒执行一次同步任务
//    @Scheduled(fixedDelay = 1000)
    public void syncAuditLog() {
        try {
            syncService.syncAuditLogs();
            queryLogSyncService.syncAuditQueryLogs();
        } catch (Exception e) {
            log.error("审计日志同步任务执行异常", e);
        }
    }
}
